<template>
  <el-card
    class="card"
    :body-style="{ padding: '10px' }"
    shadow="hover"
    @click="this.$router.push({ path: '/commodity/', query: {id: commodityId}})"
  >
    <div style="display: flex; justify-content: center">
      <el-image :src="url" class="pic">
        <template #placeholder>
          <div class="image-slot">Loading<span class="dot">...</span></div>
        </template>
      </el-image>
    </div>

    <div class="content">
      {{ name }}
    </div>
    <div style="font-weight: 900; color: #e60012; margin-top: 10px">
      <span>￥{{ price }}</span>
    </div>
  </el-card>
</template>

<script>
export default {
  props: {
    url: String,
    price: String,
    name: String,
    commodityId: Number,
  },
};
</script>

<style scoped>
.card {
  width: 100%;
  height: 300px;
  background-color: #f5f3f2;
  cursor: pointer;
}

.content {
  overflow: hidden;
  -webkit-line-clamp: 2;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.pic {
  width: 200px;
  height: 200px;
  margin-bottom: 10px;
}
</style>